package com.lc.redis;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @author liuc
 * @date 2021/8/11
 * @description
 **/
@SpringBootApplication
@EnableCaching
public class RunBoot {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(RunBoot.class, args);
        RedisTemplate<String, Object> redisTemplate = context.getBean("redisTemplate", RedisTemplate.class);
        redisTemplate.opsForValue().set("name","liuc");
        Object name = redisTemplate.opsForValue().get("name");
        System.out.println(name);
        redisTemplate.opsForValue().set("age","18");
        Object age = redisTemplate.opsForValue().get("age");
        System.out.println(age);
        redisTemplate.opsForValue().set("role:1","admin");
        Object role1 = redisTemplate.opsForValue().get("role:1");
        System.out.println(role1);

    }
}
